﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}

<script src="~/Content/adminDefault/js/default.js"></script>
<script>
    var _organizeid = "", _pstructId = "", _state = "", _psallname = ""; _type = 2;
    $(function () {
        InitialPage();
        GetTree();
        GetGrid();
    });
    //初始化页面
    function InitialPage() {
        //layout布局
        $('#layout').layout({
            applyDemoStyles: true,
            onresize: function () {
                $(window).resize()
            }
        });
        //resize重设(表格、树形)宽高
        $(window).resize(function (e) {
            window.setTimeout(function () {
                $('#gridTable').setGridWidth(($('.gridPanel').width()));
                $("#gridTable").setGridHeight($(window).height() - 165.5);
                $("#itemTree1").setTreeHeight($(window).height() - 624.5);
                $("#itemTree2").setTreeHeight($(window).height() - 381.5);
            }, 200);
            e.stopPropagation();
        });
        //组织机构
        $("#PStructTree").ComboBoxTree({
            url: "../../BaseManage/Organize/GetTreeJson",
            description: "==请选择组织机构==",
            height: "250px",
            click: function (item) {
                if (_organizeid != item.id) {
                    _organizeid = item.id;
                    GetTree2();
                    _psallname = item.text;
                    $('#btn_Search').trigger("click");
                }
            }
        });
    }

    function GetTree() {
        var item = {
            height: $(window).height() - 352,
            url: "../../ResourceManage/RS_PStructs/GetTreeJson?IsSubstep=true&organizeid=" + _organizeid,
            onnodeclick: function (item) {
                _psallname = item.text;
                $('#btn_Search').trigger("click");
            }
        };
        //初始化
        $("#itemTree").treeview(item);
    }

   
    //加载表格
    function GetGrid() {
        var selectedRowIndex = 0;
        var queryJson = $("#queryCondition").GetWebControls();
        queryJson["State"] = "All";
        queryJson["PSAllName"] = "ALL";
        queryJson["condition"] = $('#queryCondition').find('.dropdown-text').attr('data-value');
        var $gridTable = $('#gridTable');
        $gridTable.jqGrid({
            url: "../../PropertyManage/CS_Decorate/GetPageListJson",
            postData: { queryJson: JSON.stringify(queryJson) },
            datatype: "json",
            height: $(window).height() - 165.5,
            autowidth: true,
            colModel: [
                { label: "主键", name: "Id", hidden: true },
                { label: "商铺名称", name: "Code", index: "Code", width: 80, align: "left" },
                { label: "出场时间", name: "Date", index: "Date", width: 80, align: "left" },
                { label: "出厂货物类型", name: "PStructName", index: "PStructName", width: 80, align: "left" },
                { label: "出场货物详情", name: "Cname", index: "Cname", width: 80, align: "left" },
                { label: "登记人", name: "Ccode", index: "Ccode", width: 80, align: "center" },
                { label: "手机号码", name: "Area", index: "Area", width: 80, align: "left" },
                { label: "记录人", name: "Brand", index: "Brand", width: 80, align: "left" },
                { label: "说明", name: "ConstructionUnit", index: "ConstructionUnit", width: 100, align: "left" },
            ],
            viewrecords: true,
            rowNum: 30,
            rowList: [30, 50, 100],
            pager: "#gridPager",
            sortname: 'Date',
            sortorder: 'desc',
            rownumbers: true,
            shrinkToFit: false,
            gridview: true,
            onSelectRow: function (status) {
                selectedRowIndex = $("#" + this.id).getGridParam('selrow');
            },
            gridComplete: function () {
                $("#" + this.id).setSelection(selectedRowIndex, false);
            }
        });
        //查询条件
        $("#queryCondition .dropdown-menu li").click(function () {
            var text = $(this).find('a').html();
            var value = $(this).find('a').attr('data-value');
            $("#queryCondition .dropdown-text").html(text).attr('data-value', value)
        });
        //查询事件
        $("#btn_Search").click(function () {
            GetDynamicCols();
        });
        //查询回车
        $('#keyword').bind('keypress', function (event) {
            if (event.keyCode == "13") {
                $('#btn_Search').trigger("click");
            }
        });
    }

</script>

<div class="ui-layout" id="layout" style="height: 100%; width: 100%;">
    <div class="ui-layout-west">
        <div class="west-Panel" style="height:97.5%;">
            <div class="panel-Title" style="height:28px;padding-left:0px;"><div id="PStructTree" type="selectTree" class="ui-select"></div></div>
            <div id="itemTree"></div>
        </div>
    </div>
    <div class="ui-layout-center">
        <div class="center-Panel">
            <div class="panel-Title">货品出场信息</div>
            <div class="titlePanel">
                <div class="title-search">
                    <table id="queryCondition">
                        <tr>
                            <td>查询条件</td>
                            <td style="padding-left: 10px;">
                                <div class="ui-filter" style="width: 200px;">
                                    <div class="ui-filter-text">
                                        <strong id="SelectedStartTime">@DateTime.Now.AddDays(1 - Convert.ToInt32(DateTime.Now.DayOfYear)).ToString("yyyy-MM-dd")</strong> 至 <strong id="SelectedEndTime">@DateTime.Now.AddDays(-Convert.ToInt32(DateTime.Now.DayOfYear)).AddYears(1).ToString("yyyy-MM-dd")</strong>
                                    </div>
                                    <div class="ui-filter-list" style="width: 350px;">
                                        <table class="form" id="filter-form">
                                            <tr>
                                                <th class="formTitle">巡检时间：</th>
                                                <td class="formValue">
                                                    <div style="float: left; width: 45%;">
                                                        <input id="StartTime" readonly type="text" value="@LeSoft.Util.Time.GetDate(1 - Convert.ToInt32(DateTime.Now.DayOfYear))" class="form-control input-wdatepicker" onfocus="WdatePicker({maxDate:'%y-%M-%d'})">
                                                    </div>
                                                    <div style="float: left; width: 10%; text-align: center;">至</div>
                                                    <div style="float: left; width: 45%;">
                                                        <input id="EndTime" readonly type="text" value="@DateTime.Now.AddDays(-Convert.ToInt32(DateTime.Now.DayOfYear)).AddYears(1).ToString("yyyy-MM-dd")" class="form-control input-wdatepicker" onfocus="WdatePicker({})">
                                                    </div>
                                                </td>
                                            </tr>
                                        </table>
                                    </div>
                                </div>
                            </td>
                        </tr>
                    </table>
                </div>
                <div class="toolbar">
                    <div class="btn-group">
                        <a id="lr-replace" class="btn btn-default" onclick="reload();"><i class="fa fa-refresh"></i>&nbsp;刷新</a>
                        <a id="lr-add" class="btn btn-default" onclick="btn_add()"><i class="fa fa-plus"></i>&nbsp;新增</a>
                        <a id="lr-edit" class="btn btn-default" onclick="btn_edit()"><i class="fa fa-pencil-square-o"></i>&nbsp;编辑</a>
                        <a id="lr-delete" class="btn btn-default" onclick="btn_delete()"><i class="fa fa-trash-o"></i>&nbsp;删除</a>
                    </div>
                    <script>$('.toolbar').authorizeButton()</script>
                </div>
            </div>
            <div class="gridPanel">
                <table id="gridTable"></table>
                <div id="gridPager"></div>
            </div>
        </div>
    </div>
</div>

